package solver

type Strategy func() bool

func (g *Grid) prepareStrategies() {

	g.strategies = append(g.strategies, g.LastOne)
	g.strategyNames = append(g.strategyNames, "LastOne")

	g.strategies = append(g.strategies, g.HiddenSingleInBoxes)
	g.strategyNames = append(g.strategyNames, "HiddenSingleInBoxes")

	g.strategies = append(g.strategies, g.HiddenSingleInRows)
	g.strategyNames = append(g.strategyNames, "HiddenSingleInRows")

	g.strategies = append(g.strategies, g.NakedSingle)
	g.strategyNames = append(g.strategyNames, "HiddenSingleInCols")

	g.strategies = append(g.strategies, g.HiddenSingleInCols)
	g.strategyNames = append(g.strategyNames, "NakedSingle")
}

func (g *Grid) Solve() {
	g.prepareStrategies()

	used := false

	for {
		for _, strategy := range g.strategies {
			used = strategy()
			if used {
				//fmt.Println(g.strategyNames[i])
				break
			}
		}

		if !used {
			break
		}
		used = false
	}
}
